package com.ruibang.glass.quality.controller.ll;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.quality.domain.req.SpacerPaperReq;
import com.ruibang.glass.quality.entity.SpacerPaper;
import com.ruibang.glass.quality.service.SpacerPaperService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * <p>
 * 来料-间隔纸 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-05-21
 */
@RestController

@RequestMapping("/api/quality/spacer/paper")
@Api(value = "来料-间隔纸控制器", tags = {"来料-间隔纸接口"})
public class SpacerPaperController {

    @Autowired
    private SpacerPaperService spacerPaperService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取来料-间隔纸", notes = "获取来料-间隔纸")
    public ResultBody getById(@PathVariable(value = "id") Integer id) {
        return ResultBody.success(spacerPaperService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增来料-间隔纸", notes = "新增来料-间隔纸")
    public ResultBody save(@RequestBody SpacerPaper spacerPaper) {
        spacerPaperService.saveInfo(spacerPaper);
        return ResultBody.success();
    }

    @GetMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除来料-间隔纸", notes = "通过ID删除来料-间隔纸")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        spacerPaperService.removeById(id);
        return ResultBody.success();
    }

    @PostMapping("/edit")
    @ApiOperation(value = "修改来料-间隔纸", notes = "修改来料-间隔纸")
    public ResultBody edit(@RequestBody SpacerPaper spacerPaper) {
        spacerPaperService.edit(spacerPaper);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询来料-间隔纸", notes = "分页列表查询来料-间隔纸")
    public ResultBody<IPage<SpacerPaper>> pageQuery(@RequestBody SpacerPaperReq spacerPaperReq) {
        return ResultBody.success(spacerPaperService.pageQuery(spacerPaperReq));
    }

    @PostMapping("/importExcel")
    @ApiOperation(value = "导入取数", notes = "导入取数")
    public ResultBody<SpacerPaper> importExcel(@RequestParam("file") MultipartFile file) {
        return ResultBody.success(spacerPaperService.importExcel(file));
    }


}
